import numpy as np

def sigmoid(x):
    return 1 / (1 + np.exp(-x))

# 输入层到第一层的传递
X = np.array([1, 0.5])
W1 = np.array([[0.1, 0.3, 0.5],
               [0.2, 0.4, 0.6]])
B1 = np.array([0.1, 0.2, 0.3])

A1 = np.dot(X, W1) + B1 # 第一层的加权和
Z1 = sigmoid(A1)

print(X.shape)
print(W1.shape)
print(B1.shape)
print(A1)
print(Z1)

# 第一层到第二层的传递
W2 = np.array([[0.1, 0.4],
               [0.2, 0.5],
               [0.3, 0.6]])
B2 = np.array([0.1, 0.2])

A2 = np.dot(Z1, W2) + B2
Z2 = sigmoid(A2)

print(A2)
print(Z2)

# 第二层到输出层的传递
def identity_function(x): # 恒等函数
    return x

W3 = np.array([[0.1, 0.3],
               [0.2, 0.4]])
B3 = np.array([0.1, 0.2])

A3 = np.dot(Z2, W3) + B3
Y = identity_function(A3)

print(A3)
print(Y)
